//
//  SubScribeCell.m
//  RENTVISITOR
//
//  Created by wonder on 2017/9/20.
//  Copyright © 2017年 UNN. All rights reserved.
//

#import "SubScribeCell.h"
#import "RentVieitor.h"

@implementation SubScribeCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self creatView];
    }
    return self;
}

- (void)creatView {
    
   
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(12.5, 0, KWidth-25, self.frame.size.height)];
    imgView.image = [UIImage imageNamed:@"sub_即将到来的预约"];
    [self.contentView addSubview:imgView];
    
    UIImageView *selctView = [[UIImageView alloc] initWithFrame:CGRectMake(10, (imgView.frame.size.height-20)/2, 20, 20)];
    selctView.image = [UIImage imageNamed:@"sub_选中-拷贝-2"];
    [imgView addSubview:selctView];
    
    UILabel *introduce = [[UILabel alloc] init];
    introduce.text = @"紧邻十五号地铁 家电齐全 双南向,紧邻十五号地铁 家电齐全 双南向.";
    introduce.numberOfLines = 2;
    introduce.font = [UIFont boldSystemFontOfSize:15];
    introduce.textColor = [UIColor whiteColor];
    introduce.textAlignment = NSTextAlignmentLeft;
    [imgView addSubview:introduce];
    
    [introduce mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(imgView.mas_left).with.offset(40);
        make.top.mas_equalTo(imgView.mas_top).with.offset(10);
        make.right.mas_equalTo(imgView.mas_right).with.offset(-10);
        make.height.mas_equalTo(@(40));
    }];

    NSArray *imgArray = @[@"sub_条件_白色",@"sub_menu",@"sub_menu",@"sub_预约",@"人"];
    NSArray *titleArray = @[@"房源概况:",@"房源编号:",@"内部编号:",@"预约时间:",@"租客信息:"];
    NSArray *contentArray = @[@"两室一厅|83m|朝南:",@"133454465:",@"liaoxiangpeng",@"2017-9-20",@"廖湘鹏"];
    CGFloat hight = 11;
    CGFloat margin = 8;
    for (int i=0; i<imgArray.count; i++) {
        
        UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(40, 60+(margin+hight)*i, 11, 11)];
        imgView2.image = [UIImage imageNamed:imgArray[i]];
        [imgView addSubview:imgView2];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = titleArray[i];
        titleLabel.font = [UIFont boldSystemFontOfSize:11];
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        [imgView addSubview:titleLabel];
        CGSize size = [titleArray[i] boundingRectWithSize:CGSizeMake(KWidth, 15) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titleLabel.font} context:nil].size;
        titleLabel.frame = CGRectMake(53, 60+(margin+hight)*i, size.width, 11);
        
        UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(53+size.width+3, 60+(margin+hight)*i, imgView.frame.size.width-(53+size.width+10), 11)];
        contentLabel.text = contentArray[i];
        contentLabel.font = [UIFont boldSystemFontOfSize:11];
        contentLabel.textColor = [UIColor whiteColor];
        contentLabel.textAlignment = NSTextAlignmentLeft;
        [imgView addSubview:contentLabel];

    }
    
    UIButton *deleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    deleBtn.frame = CGRectMake(imgView.frame.size.width - 70, imgView.frame.size.height-30, 60, 30);
    [deleBtn setImage:[UIImage imageNamed:@"sub_关闭"] forState:UIControlStateNormal];
    [deleBtn setTitle:@" 关闭" forState:UIControlStateNormal];
    [deleBtn addTarget:self action:@selector(delegateAction) forControlEvents:UIControlEventTouchUpInside];
    deleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [imgView addSubview:deleBtn];



}

- (void)delegateAction {
    
}

@end
